package service.impl;

import dao.UserDao;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import service.UserService;

public class UserServiceImpl implements UserService {
    private UserDao userDao;

    //通过set方法实现UserDao对象注入到Spring容器
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    //通过构造方法实现UserDao对象注入到Spring容器
    public UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }

    public UserServiceImpl() {
    }

    @Override
    public void doSave() {
        //通过配置文件获取userDao对象
//        ClassPathXmlApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");
//        UserDao userDao = (UserDao) app.getBean("userDao");
        userDao.save();
    }
}
